<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@include file="/pages/system/base.jsp"%>
<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>教师</title>
</head>
<body>
	<table id="dg" class="" title="列表" style="width: 700px; height: 300px">
		<thead>
			<tr>
				<th data-options="field:'ck',checkbox:true"></th>
				<th data-options="field:'instituteid',width:80">编号</th>
				<th data-options="field:'institute',width:80">学院</th>
				<th data-options="field:'detail',width:80">详情</th>
				<th data-options="field:'other',width:80">其它</th>
			</tr>
		</thead>
	</table>
	<div id="toolbar">
		<a href="#" class="easyui-linkbutton add" iconCls="icon-add" onclick="create()" plain="true">新增</a> 
	</div>
	<div id="dlg" class="easyui-dialog" title="数据参数" data-options="modal:true" style="width: 360px; height: 300px;" closed="true" buttons="#dlg-buttons">
		<form method="post" id="fm">
			<table cellpadding="5">
	    		<tr>
	    			<td>编号:</td>
	    			<td><input class="easyui-textbox" type="text" id="instituteid" name="instituteid" maxlength="30" required="true" validtype="intOrFloat" missingMessage="必须填写"></input></td>
	    		</tr>
	    		<tr>
	    			<td>学院:</td>
	    			<td><input class="easyui-textbox" type="text" id="institute" name="institute" maxlength="30" required="true" missingMessage="必须填写"></input></td>
	    		</tr>
	    		<tr>
	    			<td>详情:</td>
	    			<td><input class="easyui-textbox" type="text" id="detail" name="detail" maxlength="30"></input></td>
	    		</tr>
	    		<tr>
	    			<td>其它:</td>
	    			<td><input class="easyui-textbox" id="other" type="text" name="other"  ></input></td>
	    		</tr>
	    	</table>
		</form>
	</div>
	
	<div id="dlg-buttons">
		<a href="#" class="easyui-linkbutton  save" onclick="save()" iconCls="icon-ok">保存</a> 
		<a href="#" class="easyui-linkbutton cancel" onclick="javascript:$('#dlg').dialog('close')" iconCls="icon-cancel">取消</a>
	</div>
	
	<script type="text/javascript">
	$(function() {  
		loadDataGrid();
    });  	
	function loadDataGrid(queryConditon){
		 $('#dg').datagrid({  
	            title : '学院信息',  
	            iconCls : 'icon-ok',  
	            pageSize : 10,
	            pageList : [ 10, 15, 20 ],
	            nowrap : true,
	            striped : true,
	            collapsible : true,  
	            toolbar:"#toolbar", 
	            url:'instituteController.do?datagrid',
	            loadMsg : '数据装载中......',  
	            singleSelect:false,
	            fitColumns:true,  
	            checkOnSelect:true,
	            selectOnCheck:true,
	            fit:true,
	            remoteSort : false,  
	            pagination : true,  
	            rownumbers : true,
	            queryParams:queryConditon
	        });   
	}
		var url;
		function create(){
			$('#dlg').dialog('open').dialog('setTitle','新建');
			$('#fm').form('clear');
			url = 'instituteController.do?save';
		}
		
		function save(){
			$('#fm').form('submit',{
				url: url,
				onSubmit: function(){
					var ret = $(this).form('validate');
					return ret;
				},
				success: function(result){
					var result = eval('('+result+')');
					$.messager.show({
						title: '提示信息',
						msg: 'result  '+result
					});
					if (result.success){
						$('#dlg').dialog('close');		
						$('#dg').datagrid('reload');	
						$.messager.show({
							title: '提示信息',
							msg: result.msg
						});
					} else {
						$.messager.show({
							title: '提示信息',
							msg: result.msg
						});
					}
				}
			});
		}
		function getintitute(value,row,rowIndex) {
            if(row.institute!=undefined){
                return row.institute.institute;
            }
        }
	</script>
	
</body>
</html>